<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUniqidOpenidTable extends Migration
{
    const TABLE_NAME = 'uniqid_openid';
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create(self::TABLE_NAME, function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->increments('id');
            $table->char('openid', 64)->default('')->comment('微信openid');
            $table->char('uniqid', 64)->default('')->comment('跨session_uniqid');
            $table->index(['openid', 'uniqid']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        if (Schema::hasTable(self::TABLE_NAME)) {
            Schema::drop(self::TABLE_NAME);
        }
    }
}
